﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.iOS.NotificationServices
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Runtime.CompilerServices;
using UnityEngine.Bindings;

#nullable disable
namespace UnityEngine.iOS
{
  /// <summary>
  ///   <para>NotificationServices is only available on iPhoneiPadiPod Touch.</para>
  /// </summary>
  [NativeConditional("PLATFORM_IOS || PLATFORM_TVOS")]
  [NativeHeader("PlatformDependent/iPhonePlayer/Notifications.h")]
  [Obsolete("iOS.Notification Services is deprecated. Consider using the Mobile Notifications package (available in the package manager) which implements the UserNotifications framework.")]
  public sealed class NotificationServices
  {
    /// <summary>
    ///   <para>The number of received local notifications. (Read Only)</para>
    /// </summary>
    public static extern int localNotificationCount { [FreeFunction("NotificationScripting::GetLocalCount"), MethodImpl(MethodImplOptions.InternalCall)] get; }

    /// <summary>
    ///   <para>The number of received remote notifications. (Read Only)</para>
    /// </summary>
    public static extern int remoteNotificationCount { [FreeFunction("NotificationScripting::GetRemoteCount"), MethodImpl(MethodImplOptions.InternalCall)] get; }

    /// <summary>
    ///   <para>Discards of all received local notifications.</para>
    /// </summary>
    [FreeFunction("NotificationScripting::ClearLocal")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public static extern void ClearLocalNotifications();

    /// <summary>
    ///   <para>Discards of all received remote notifications.</para>
    /// </summary>
    [FreeFunction("NotificationScripting::ClearRemote")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public static extern void ClearRemoteNotifications();

    [FreeFunction("RegisterForNotifications")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern void Internal_RegisterImpl(
      NotificationType notificationTypes,
      bool registerForRemote);

    /// <summary>
    ///   <para>Register to receive local and remote notifications of the specified types from a provider via Apple Push Service.</para>
    /// </summary>
    /// <param name="notificationTypes">Notification types to register for.</param>
    /// <param name="registerForRemote">Specify true to also register for remote notifications.</param>
    public static void RegisterForNotifications(NotificationType notificationTypes)
    {
      NotificationServices.Internal_RegisterImpl(notificationTypes, true);
    }

    /// <summary>
    ///   <para>Register to receive local and remote notifications of the specified types from a provider via Apple Push Service.</para>
    /// </summary>
    /// <param name="notificationTypes">Notification types to register for.</param>
    /// <param name="registerForRemote">Specify true to also register for remote notifications.</param>
    public static void RegisterForNotifications(
      NotificationType notificationTypes,
      bool registerForRemote)
    {
      NotificationServices.Internal_RegisterImpl(notificationTypes, registerForRemote);
    }

    /// <summary>
    ///   <para>Enabled local and remote notification types.</para>
    /// </summary>
    public static extern NotificationType enabledNotificationTypes { [FreeFunction("GetEnabledNotificationTypes"), MethodImpl(MethodImplOptions.InternalCall)] get; }

    /// <summary>
    ///   <para>Schedules a local notification.</para>
    /// </summary>
    /// <param name="notification"></param>
    public static void ScheduleLocalNotification(LocalNotification notification)
    {
      notification.Schedule();
    }

    /// <summary>
    ///   <para>Presents a local notification immediately.</para>
    /// </summary>
    /// <param name="notification"></param>
    public static void PresentLocalNotificationNow(LocalNotification notification)
    {
      notification.PresentNow();
    }

    /// <summary>
    ///   <para>Cancels the delivery of the specified scheduled local notification.</para>
    /// </summary>
    /// <param name="notification"></param>
    public static void CancelLocalNotification(LocalNotification notification)
    {
      notification.Cancel();
    }

    /// <summary>
    ///   <para>Cancels the delivery of all scheduled local notifications.</para>
    /// </summary>
    [FreeFunction("iPhoneLocalNotification::CancelAll")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public static extern void CancelAllLocalNotifications();

    /// <summary>
    ///   <para>Unregister for remote notifications.</para>
    /// </summary>
    [FreeFunction("iPhoneRemoteNotification::Unregister")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public static extern void UnregisterForRemoteNotifications();

    /// <summary>
    ///   <para>Returns an error that might occur on registration for remote notifications via NotificationServices.RegisterForRemoteNotificationTypes. (Read Only)</para>
    /// </summary>
    public static extern string registrationError { [FreeFunction("iPhoneRemoteNotification::GetError"), MethodImpl(MethodImplOptions.InternalCall)] get; }

    /// <summary>
    ///   <para>Device token received from Apple Push Service after calling NotificationServices.RegisterForRemoteNotificationTypes. (Read Only)</para>
    /// </summary>
    public static extern byte[] deviceToken { [FreeFunction("NotificationScripting::GetDeviceToken"), MethodImpl(MethodImplOptions.InternalCall)] get; }

    [FreeFunction("NotificationScripting::GetLocal")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern LocalNotification GetLocalNotificationImpl(int index);

    /// <summary>
    ///   <para>Returns an object representing a specific local notification. (Read Only)</para>
    /// </summary>
    /// <param name="index"></param>
    public static LocalNotification GetLocalNotification(int index)
    {
      return index >= 0 && index < NotificationServices.localNotificationCount ? NotificationServices.GetLocalNotificationImpl(index) : throw new ArgumentOutOfRangeException(nameof (index), "Index out of bounds.");
    }

    /// <summary>
    ///   <para>The list of objects representing received local notifications. (Read Only)</para>
    /// </summary>
    public static LocalNotification[] localNotifications
    {
      get
      {
        int notificationCount = NotificationServices.localNotificationCount;
        LocalNotification[] localNotifications = new LocalNotification[notificationCount];
        for (int index = 0; index < notificationCount; ++index)
          localNotifications[index] = NotificationServices.GetLocalNotificationImpl(index);
        return localNotifications;
      }
    }

    [FreeFunction("NotificationScripting::GetRemote")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern RemoteNotification GetRemoteNotificationImpl(int index);

    /// <summary>
    ///   <para>Returns an object representing a specific remote notification. (Read Only)</para>
    /// </summary>
    /// <param name="index"></param>
    public static RemoteNotification GetRemoteNotification(int index)
    {
      return index >= 0 && index < NotificationServices.remoteNotificationCount ? NotificationServices.GetRemoteNotificationImpl(index) : throw new ArgumentOutOfRangeException(nameof (index), "Index out of bounds.");
    }

    /// <summary>
    ///   <para>The list of objects representing received remote notifications. (Read Only)</para>
    /// </summary>
    public static RemoteNotification[] remoteNotifications
    {
      get
      {
        int notificationCount = NotificationServices.remoteNotificationCount;
        RemoteNotification[] remoteNotifications = new RemoteNotification[notificationCount];
        for (int index = 0; index < notificationCount; ++index)
          remoteNotifications[index] = NotificationServices.GetRemoteNotificationImpl(index);
        return remoteNotifications;
      }
    }

    /// <summary>
    ///   <para>All currently scheduled local notifications.</para>
    /// </summary>
    public static extern LocalNotification[] scheduledLocalNotifications { [FreeFunction("NotificationScripting::GetScheduledLocal"), MethodImpl(MethodImplOptions.InternalCall)] get; }
  }
}
